m = 3
n = 3
operations = [[2,2],[3,3]]
# m=40000
# n=40000
# operations=[]
#这种方式会超时
def maxCount(m,n, ops):
    M=[[0 for _ in range(n)] for _ in range(m)]
    print(M)
    for i in ops:
        #所有符合0<=i< a and 0<=j<b的M[i][j]都加1
        for j in range(0,i[0]):
            for k in range(0,i[1]):
                M[j][k]+=1
    maxValue=0
    for i in range(len(M)):
        for j in range(len(M[0])):
            if maxValue<M[i][j]:
                maxValue=M[i][j]
    count=0
    for i in range(len(M)):
        for j in range(len(M[0])):
            if M[i][j]==maxValue:
                count+=1

    print(M)
    return count
def maxCount1(m,n, ops):
    #先对ops进行判断
    opsLength=len(ops)
    if opsLength==0:
        return m*n
    ops1=ops
    ops1.sort(key=lambda x:x[0])
    rowMinValue=ops1[0][0]
    ops1.sort(key=lambda x:x[1])
    colMinValue=ops1[0][1]
    return rowMinValue*colMinValue

def maxCount2(m,n,ops):
    #先对ops进行判断
    opsLength=len(ops)
    if opsLength==0:
        return m*n
    rowMinValue=ops[0][0]
    colMinValue=ops[0][1]
    for i in range(opsLength):
        if rowMinValue>ops[i][0]:
            rowMinValue=ops[i][0]
        if colMinValue>ops[i][1]:
            colMinValue=ops[i][1]
    return rowMinValue*colMinValue

print(maxCount2(m,n,operations))
